﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Tanmia.Core;
using FluentNHibernate.Mapping;

namespace Tanmia.NHibernate.Mapping
{
    public class UserMap : ClassMap<User>
    {
        public UserMap()
        {
            Table("ProgramUser");

            Id(x => x.UserID).Not.Nullable().GeneratedBy.Identity();

            Map(x => x.Name).Not.Nullable().Unique().Length(64);
            Map(x => x.Image);
            Map(x => x.Password).Not.Nullable().Unique().Length(256);
            Map(x => x.FirstSQ).Nullable().Unique().Length(128);
            Map(x => x.FirstSA).Nullable().Unique().Length(128);
            Map(x => x.SecoundSQ).Nullable().Unique().Length(128);
            Map(x => x.SecoundSA).Nullable().Unique().Length(128);
            Map(x => x.FirstName).Not.Nullable().Unique().Length(32);
            Map(x => x.MiddleName).Nullable().Unique().Length(32);
            Map(x => x.LastName).Not.Nullable().Unique().Length(32);
            Map(x => x.CreateDate).Not.Nullable().Not.Update();
            Map(x => x.Note).Nullable().Length(2048);

            HasMany(x => x.Details).KeyColumn("UserID").Cascade.SaveUpdate();

        }
    }
}
